package com.topfinance.cnaps2.util;

import java.io.File;

public class CdbCommonUtil {
	public static String retrieveTemplateName(File[] files, String bizProCode,
			String splitMark) {
		if (files == null || files.length == 0) {
			return null;
		}
		if (bizProCode == null || bizProCode.length() == 0) {
			return null;
		}			
		int len = files.length;
		File file = null;
		String fileName=null;
		for (int i = 0; i < len; i++) {
			file = files[i];
			fileName = file.getName();
			if (bizProCode.equals(fileName.substring(0,
					fileName.lastIndexOf(splitMark)))) {
				return fileName;
			}
		}
		return null;
	}
	
	public static File retrieveTemplateFile(File[] files, String bizProCode,
			String splitMark) {
		if (files == null || files.length == 0) {
			return null;
		}
		if (bizProCode == null || bizProCode.length() == 0) {
			return null;
		}		
		int len = files.length;
		File file = null;
		String fileName=null;
		for (int i = 0; i < len; i++) {
			file = files[i];
			fileName = file.getName();
			if (bizProCode.equals(fileName.substring(0,
					fileName.lastIndexOf(splitMark)))) {
				return file;
			}
		}
		return null;
	}
}
